//
//  NotifyCell.swift
//  TrafficViolation
//
//  Created by eaglelive on 2017/6/23.
//  Copyright © 2017年 eaglelive. All rights reserved.
//

import Foundation
class NotifyCell: UITableViewCell {
    var nTitle,nTime,nBody:UILabel!
    override init(style: UITableViewCellStyle, reuseIdentifier: String?) {
        super.init(style: style, reuseIdentifier: reuseIdentifier)
        self.selectionStyle = UITableViewCellSelectionStyle.none
        self.layer.borderWidth = 0
        self.backgroundColor = tableBgColor
        // 背景view
        let backgroundView = UIView()
        backgroundView.layer.borderColor = colorFromHex(0xeeeeee).cgColor
        backgroundView.layer.borderWidth = 1
        backgroundView.layer.cornerRadius = 5
        backgroundView.layer.masksToBounds = true
        backgroundView.backgroundColor = UIColor.white
        self.addSubview(backgroundView)
        backgroundView.snp.makeConstraints { (make) in
            make.left.equalTo(self).offset(10)
            make.top.equalTo(self).offset(10)
            make.right.equalTo(self).offset(-10)
            make.bottom.equalTo(self)
        }
        nTitle = UILabel()
        nTitle.font = UIFont.systemFont(ofSize: 17)
        backgroundView.addSubview(nTitle)
        nTitle.snp.makeConstraints { (make) in
            make.top.equalTo(backgroundView.snp.top)
            make.width.equalTo(backgroundView.snp.width)
            make.height.equalTo(cellH)
            make.left.equalTo(backgroundView.snp.left).offset(5)
        }
        
        nTime = UILabel()
        nTime.font = UIFont.systemFont(ofSize: 13)
        nTime.textColor = UIColor.lightGray
        backgroundView.addSubview(nTime)
        nTime.snp.makeConstraints { (make) in
            make.top.equalTo(nTitle.snp.bottom).offset(-10)
            make.width.equalTo(backgroundView.snp.width)
            make.height.equalTo(25)
            make.left.equalTo(backgroundView.snp.left).offset(5)
        }
        nBody = UILabel()
        nBody.font = UIFont.systemFont(ofSize: 13)
        nBody.numberOfLines = 0
        nBody.lineBreakMode = .byCharWrapping
        backgroundView.addSubview(nBody)
        nBody.snp.makeConstraints { (make) in
            make.top.equalTo(nTime.snp.bottom)
            make.left.equalTo(backgroundView.snp.left).offset(5)
            make.bottom.equalTo(backgroundView.snp.bottom).offset(-5)
            make.right.equalTo(backgroundView.snp.right).offset(-5)
        }
    }
    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    func configCellDateWithModel(_ model:NotifyModel) {
        nTitle.text = model.nTitle
        nTime.text =  model.nTime
        nBody.text =  model.nBody
    }
}
